package com.example.myapplication;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.List;

public class Adapter extends ArrayAdapter<String> {
    private int resource;
    private TextView tx;
    public Adapter(@NonNull Context context, int resource, @NonNull List<String> objects) {
        super(context, resource, objects);
        this.resource =resource;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        String s =getItem(position);
        if (convertView == null){
            convertView = LayoutInflater.from(getContext()).inflate(resource,parent,false);
        }
        tx = convertView.findViewById(R.id.tx);
        tx.setText(s);
        return convertView;
    }
}
